package cn.tedu.csmall.product.config;

import org.hibernate.validator.HibernateValidator;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.validation.Validation;
import javax.validation.Validator;

@Configuration
public class ValidationConfiguration {
    @Bean
    public Validator validator(){
        return Validation.byProvider(HibernateValidator.class)
                .configure() //开始配置
                .failFast(true) //快速配置
                .buildValidatorFactory() //构建Validator工厂
                .getValidator(); //从Validator工厂获取Validator对象
    }
}
